//
//  playView.m
//  开心一刻
//
//  Created by lanou on 16/4/9.
//  Copyright © 2016年 刘洋. All rights reserved.
//

#import "playView.h"

@implementation playView
- (instancetype)initWithFrame:(CGRect)frame url:(NSString *)url
{
    self = [super initWithFrame:frame];
    if (self)
    {
        AVPlayerItem * item = [AVPlayerItem playerItemWithURL:[NSURL URLWithString:url]];
        
        self.player = [AVPlayer playerWithPlayerItem:item];
        AVPlayerLayer * layer = [AVPlayerLayer playerLayerWithPlayer:_player];
        
        layer.frame = frame;
        [self.layer insertSublayer:layer atIndex:0];
        [_player play];
    
            }
    return self;
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
